#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N=2e5;
const int maxn=1e6;
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
//----------------------------------------------------------------------------//
ll qpow(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=ans*a%mod;
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

void solve(){
    ll n;
    sld(n);
    ll ans=n*(n+1)%mod*(2*n+1)%mod*qpow(6,mod-2)%mod;

    ll ans_2=n*(n-1)%mod*(2*n-1)%mod*qpow(6,mod-2)%mod;

    ans=((ans+ans_2)%mod+n*(n-1)/2)%mod;

    cout<<ans*2022%mod;
    puts("");
}


int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}